<?php

use yii\helpers\Html;
use yii\helpers\Url;
use yii\grid\GridView;

/**
 * @var yii\web\View $this
 * @var yii\data\ActiveDataProvider $dataProvider
 * @var yiike\company\model\TtycTokerSearch $searchModel
 */

$this->title = Yii::t('models', '商圈管理');
$this->params['breadcrumbs'][] = $this->title;

if (isset($actionColumnTemplates)) {
    $actionColumnTemplate = implode(' ', $actionColumnTemplates);
    $actionColumnTemplateString = $actionColumnTemplate;
} else {
    Yii::$app->view->params['pageButtons'] = Html::a('<span class="glyphicon glyphicon-plus"></span> ' . 'New', ['create'], ['class' => 'btn btn-success']);
    $actionColumnTemplateString = "{update} ";
}
$actionColumnTemplateString = '<div class="action-buttons">'.$actionColumnTemplateString.'</div>';
?>
<div class="box box-info giiant-crud ttyc-toker-index">
    <div class="box-header with-border">
        <div class="box-title">
            <?= Yii::t('models', '商圈管理') ?>
        </div>
    </div>
    <div class="box-body">
        <?php
        //             echo $this->render('_search', ['model' =>$searchModel]);
        ?>


        <?php \yii\widgets\Pjax::begin(['id'=>'pjax-main', 'enableReplaceState'=> false, 'linkSelector'=>'#pjax-main ul.pagination a, th a', 'clientOptions' => ['pjax:success'=>'function(){alert("yo")}']]) ?>


        <div class="clearfix crud-navigation">
            <div class="pull-left">
                <?= Html::a('<span class="glyphicon glyphicon-plus"></span> ' . '添加', ['create'], ['class' => 'btn btn-success']) ?>
            </div>

            <div class="pull-right">



            </div>
        </div>

        <hr />

        <div class="table-responsive">
            <?= GridView::widget([
                'dataProvider' => $dataProvider,
                'pager' => [
                    'class' => yii\widgets\LinkPager::className(),
                    'firstPageLabel' => '首页',
                    'lastPageLabel' => '末页',
                ],
                'filterModel' => $searchModel,
                'tableOptions' => ['class' => 'table table-striped table-bordered table-hover'],
                'headerRowOptions' => ['class'=>'x'],
                'columns' => [
                    [
                        'class' => 'yii\grid\ActionColumn',
                        'template' => $actionColumnTemplateString,
                        'buttons' => [
                            'view' => function ($url, $model, $key) {
                                $options = [
                                    'title' => Yii::t('cruds', 'View'),
                                    'aria-label' => Yii::t('cruds', 'View'),
                                    'data-pjax' => '0',
                                ];
                                return Html::a('<span class="glyphicon glyphicon-file"></span>', $url, $options);
                            }
                        ],
                        'urlCreator' => function($action, $model, $key, $index) {
                            // using the column name as key, not mapping to 'id' like the standard generator
                            $params = is_array($key) ? $key : [$model->primaryKey()[0] => (string) $key];
                            $params[0] = \Yii::$app->controller->id ? \Yii::$app->controller->id . '/' . $action : $action;
                            return Url::toRoute($params);
                        },
                        'contentOptions' => ['nowrap'=>'nowrap']
                    ],
                    'id',
                    'name',
                    'mobile',
                    'location_c',
                    [
                        'class'=>\yii\grid\DataColumn::className(),
                        'label'=>'彩豆',
                        'content'=>function($model){
                            return  $model->u->credit1;
                        }
                    ],
                    [
                        'class'=>\yii\grid\DataColumn::className(),
                        'label'=>'红包',
                        'content'=>function($model){
                            return  $model->u->credit2;
                        }
                    ],
                    [
                        'class'=>\yii\grid\DataColumn::className(),
                        'label'=>'YCT',
                        'content'=>function($model){
                            return  $model->u->credit3;
                        }
                    ],
                    [
                        'class'=>\yii\grid\DataColumn::className(),
                        'label'=>'彩磅',
                        'content'=>function($model){
                            return  $model->u->credit4;
                        }
                    ],
                    [
                        'class'=>\yii\grid\DataColumn::className(),
                        'label'=>'奖金',
                        'content'=>function($model){
                            return  $model->u->credit5;
                        }
                    ],
                    [
                        'class'=>\yii\grid\DataColumn::className(),
                        'label'=>'推客数',
                        'content'=>function($model){

                            $count = \yiike\company\model\TtycToker::find()->where(['pid' => $model->id])->count('id');
                            return $count;
                        }
                    ],

                    'created_at:datetime',

                    /*'status',*/


                    /*'location_p',*/

                    /*'location_a',*/
                    /*'bank_name',*/
                    /*'bank_number',*/
                    /*'idcard',*/
                    /*'bank_branch',*/
                    /*'alipay',*/
                    /*'weixin',*/
                ],
            ]); ?>
        </div>
        <?php \yii\widgets\Pjax::end() ?>
    </div>
</div>




